package com.bolt.convention.validation.constraints;

import com.bolt.convention.validation.validators.IDCardValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.ReportAsSingleViolation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 身份证格式校验
 */
@Documented
@Constraint(validatedBy = {IDCardValidator.class})
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
@ReportAsSingleViolation
public @interface IDCard {
    String message() default "{com.bolt.convention.validation.constraints.IDCard.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * 是否允许15位身份证通过验证
     */
    boolean allowOld() default false;

    /**
     * 是否校验18位身份证最后一位校验位
     */
    boolean checkLastCode() default false;
}
